package com.whcoding.jwt.token.util;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

/**
 * @program: spring-boot-learning
 * @description:
 * @author: whcoding
 * @create: 2022-09-22 19:11
 **/
public class AnnotatioUtil {


	/**
	 * 获取某个方法上的某个注解对象
	 *
	 * @param reqMethod       方法对象
	 * @param annotationClass 注解对象
	 * @return 注解对象
	 */
	static public Annotation getMethodAnnotation(Method reqMethod, Class<? extends Annotation> annotationClass) {
		if (null != reqMethod && reqMethod.isAnnotationPresent(annotationClass)) {
			return reqMethod.getAnnotation(annotationClass);
		}
		return null;
	}

	/**
	 * 获取某个类上的某个注解对象
	 *
	 * @param reqClass        类对象
	 * @param annotationClass 注解对象
	 * @return 注解对象
	 */
	static public Annotation getClassAnnotation(Class reqClass, Class<? extends Annotation> annotationClass) {
		if (null != reqClass && reqClass.isAnnotationPresent(annotationClass)) {
			return reqClass.getAnnotation(annotationClass);
		}
		return null;
	}
}
